package org.dromara.system.business.team.service.impl;

import jakarta.annotation.Resource;
import org.dromara.system.business.team.entity.TeamManage;
import org.dromara.system.business.team.dao.TeamManageDao;
import org.dromara.system.business.team.service.TeamManageService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;



/**
 * (TeamManage)表服务实现类
 *
 * @author makejava
 * @since 2025-02-07 16:37:59
 */
@Service("teamManageService")
public class TeamManageServiceImpl implements TeamManageService {
    @Resource
    private TeamManageDao teamManageDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TeamManage queryById(Long id) {
        return this.teamManageDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param teamManage 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<TeamManage> queryByPage(TeamManage teamManage, PageRequest pageRequest) {
        long total = this.teamManageDao.count(teamManage);
        return new PageImpl<>(this.teamManageDao.queryAllByLimit(teamManage, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param teamManage 实例对象
     * @return 实例对象
     */
    @Override
    public TeamManage insert(TeamManage teamManage) {
        this.teamManageDao.insert(teamManage);
        return teamManage;
    }

    /**
     * 修改数据
     *
     * @param teamManage 实例对象
     * @return 实例对象
     */
    @Override
    public TeamManage update(TeamManage teamManage) {
        this.teamManageDao.update(teamManage);
        return this.queryById(teamManage.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.teamManageDao.deleteById(id) > 0;
    }
}
